#include "testlib.h"
#include <bits/stdc++.h>
using namespace std;

int main(int argc, char *argv[]) {
    setName("checker for TN64C");
    registerTestlibCmd(argc, argv);

    int n = inf.readInt();
    int k = inf.readInt();

    auto getAxis = [n](int x) {
        return pair<int, int>(x / n, x % n);
    };

    auto getReal = [n](int x, int y) {
        return x * n + y;
    };

    vector<int> x(n * k);

    for(int i = 0; i < k; i ++)
        for(int j = 0; j < n; j ++)
            x[getReal(i, j)] = ouf.readInt();
    
    for(int i = 0; i < k; i ++)
        for(int j = 0; j < n; j ++)
            if(x[getReal(i, j)] < 0)
                quitf(_wa, "Integers should be non-negative");
    
    int mins = INT_MAX, maxs = INT_MIN;
    for(int i = 0; i < k; i ++) {
        int s = 0;
        for(int j = 0; j < n; j ++)
            s += x[getReal(i, j)];
        mins = min(mins, s);
        maxs = max(maxs, s);
    }
    if(maxs - mins > 1)
        quitf(_wa, "Difference of different rows is greater than 1");
    
     for(int j = 0; j < n; j ++) {
        int maxi = INT_MIN, mini = INT_MAX, sum = 0;
         for(int i = 0; i < k; i ++){
            maxi = max(maxi, x[getReal(i, j)]);
            mini = min(mini, x[getReal(i, j)]);
            sum += x[getReal(i, j)];
        }
        if(sum != j + 1) {
            quitf(_wa, "Sum of some column does not match");
        }
        if(maxi - mini > 1) {
            quitf(_wa, "Difference of different numbers in a the column is greater than 1");
        }
    }
    quitf(_ok, "Accepted");

}
